#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QIcon icon(":/1.png");
    ui->dog->setIcon(icon);
    ui->dog->setIconSize(QSize(80,80));
    ui->up->setIcon(icon);
    ui->down->setIcon(icon);
    ui->left->setIcon(icon);
    ui->right->setIcon(icon);
    ui->up->setShortcut(QKeySequence("ctrl+w"));
    ui->down->setShortcut(QKeySequence("s"));
    ui->left->setShortcut(QKeySequence("a"));
    ui->right->setShortcut(QKeySequence("d"));
    ui->up->setAutoRepeat(true);
    ui->down->setAutoRepeat(true);
    ui->left->setAutoRepeat(true);
    ui->right->setAutoRepeat(true);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_up_clicked()
{
    ui->dog->setGeometry(ui->dog->geometry().x(),ui->dog->geometry().y() - 20, ui->dog->geometry().width(), ui->dog->geometry().height());
}
void Widget::on_down_clicked()
{
    ui->dog->setGeometry(ui->dog->geometry().x(),ui->dog->geometry().y() + 20, ui->dog->geometry().width(), ui->dog->geometry().height());
}
void Widget::on_left_clicked()
{
    ui->dog->setGeometry(ui->dog->geometry().x() - 20,ui->dog->geometry().y(), ui->dog->geometry().width(), ui->dog->geometry().height());
}
void Widget::on_right_clicked()
{
    ui->dog->setGeometry(ui->dog->geometry().x() + 20,ui->dog->geometry().y(), ui->dog->geometry().width(), ui->dog->geometry().height());
}
